#include "SPI_HAL_QG.h"

#define SS_PIN      PTBD_PTBD5
#define SS_PIN_DD   PTBDD_PTBDD5

#define SD_CRC          0x95
#define SD_CMD_TIMEOUT  0xFF

#define SD_COMMAND_0            0
#define SD_COMMAND_0_RESPONSE   1

#define SD_COMMAND_24           24
#define SD_COMMAND_24_RESPONSE  1

#define SD_COMMAND_41           41
#define SD_COMMAND_41_RESPONSE  1

#define SD_COMMAND_55           55
#define SD_COMMAND_55_RESPONSE  1

#define SD_COMMAND_58           58
#define SD_COMMAND_58_RESPONSE  6   

#define SD_INIT_TIMEOUT 0xFF

#define SD_BLOCKSIZE        512
#define SD_BLOCKSIZE_BITS   9

uint8 u8SD_Initialize (void);

uint8 u8SD_SendCommand (uint8 u8command, uint8 u8commandresponse);

uint8 u8SD_WriteBlock (uint32 u32blockaddr, uint8 *u8data, uint8 u8size);

void vfnSD_UnassertSS (void);

void vfnSD_AssertSS (void);

void vfnSD_MaxClock (void);

void vfnSD_ClockInit (void);